

    \filetitle{arma}{Apply ARMA model to input series}{tseries/arma}

	\paragraph{Syntax}

\begin{verbatim}
Y = arma(X,E,Ar,Ma,Range)
\end{verbatim}

\paragraph{Input arguments}

\begin{itemize}
\item
  \texttt{X} {[} tseries {]} - Input time series from which initial
  condition will be constructed.
\item
  \texttt{E} {[} tseries {]} - Input time series with innovations;
  \texttt{NaN} values in \texttt{E} on \texttt{Range} will be replaced
  with \texttt{0}.
\item
  \texttt{Ar} {[} numeric \textbar{} empty {]} - Row vector of AR
  polynominal coefficients; if empty, \texttt{Ar\ =\ 1}; see
  Description.
\item
  \texttt{Ma} {[} numeric \textbar{} empty {]} - Row vector of MA
  polynominal coefficients; if empty, \texttt{Ma\ =\ 1}; see
  Description.
\item
  \texttt{Range} {[} numeric \textbar{} char {]} - Range on which the
  output series observations will be constructed.
\end{itemize}

\paragraph{Output arguments}

\begin{itemize}
\tightlist
\item
  \texttt{X} {[} tseries {]} - Output time series constructed by running
  an ARMA model on the input series \texttt{X} and \texttt{E}; the
  output time series also includes p initial conditions where p is the
  order of the AR polynomial.
\end{itemize}

\paragraph{Options}

\paragraph{Description}

The output series is constructed as follows:

\[ A(L) X_t = M(L) E_t \]

where \(A(L) = A_0 + A_1 L + \cdots\) and \(M(L)=M_0 + M_1 L + \cdots\)
are polynomials in lag operator \(L\) defined by the vectors \texttt{Ar}
and \texttt{Ma}. In other words,

\[ X_t = \frac{1}{A_1} \left( -A_2 X_{t-1} - A_3 X_{t-2} - \cdots
           + M_0 E_t + M_1 E_{t-1} + \cdots \right) . \]

Note that the coefficient \(A_0\) is \texttt{Ar(1)}, \(A_1\) is
\texttt{Ar(2)}, and so on.

\paragraph{Example}

Construct an AR(1) process with autoregression coefficient 0.8, built
from normally distributed innovations:

\begin{verbatim}
X = tseries(0:20,0);
E = tseries(1:20,@randn);
X = arma(X,E,[1,-0.8],[ ],1:20);
plot(X);
\end{verbatim}


